fuzz: Skip wasm-split tests on modules with __indirect_function_table - #9092
fuzz: Skip wasm-split tests on modules with __indirect_function_table#9092ArkadySkv wants to merge 2 commits into
Conversation
Avoids triggering the Emscripten special-case logic in wasm-split that reuses existing tables, which causes table corruption and fuzzer crashes. This is the short-term fix (Path A). A follow-up will address the underlying wasm-split table-reuse behavior (Path B). See WebAssembly#8106.
|
Path B Proposal (RFC) Summary This comment proposes Path B: remove the Emscripten special‑case logic and always create a fresh table for Reproducer The following minimal module reproduces the problem when wasm-split is run on it with at least one function kept in the primary module: (module
(table $__indirect_function_table 2 funcref)
(export "__indirect_function_table" (table $__indirect_function_table))
(elem (i32.const 0) $0)
(func $0 (call_indirect (i32.const 0)))
(func $1)
)Before the fix, wasm-split reuses Root cause
Export* emscriptenTableExport =
module.getExportOrNull("__indirect_function_table");
Table* singletonTable =
module.tables.size() == 1 ? module.tables[0].get() : nullptr;
bool emscriptenTableImport =
singletonTable && singletonTable->imported() &&
singletonTable->module == "env" &&
singletonTable->base == "__indirect_function_table";
if (module.features.hasReferenceTypes() && !emscriptenTableExport &&
!emscriptenTableImport) {
return;
}
// otherwise reuse the existing tableThis special case was added in #7050 because the Emscripten loader could not handle more than one table. Proposed change (Path B) Remove the Open questions Emscripten coordination. @dschuff noted earlier that the loader "just needs to figure out which table to patch." Is the Emscripten side ready, or does this PR need to be gated on a loader update? If the loader still cannot handle multiple tables, Path B would regress Emscripten builds. Alternative: Keep the reuse behavior but make wasm-split refuse to split when the module has Test coverage. What lit tests and Emscripten integration tests should be added before this lands? Plan Path A (fuzzer skip) lands first to stop the fuzzer crashes. |
Fixes CI lint error (bare-except).
|
Looking back at #8106, it looks like the best fix would be to have Emscripten correctly handle the presence of a second table and then remove the table reuse logic in wasm-split. Is that what you mean by this in the PR description?
If so, do we even need this intermediate fix? If there are no plans to update Emscripten in the near term, though, then this fix looks good to me. |
Problem:
wasm-splitreuses an existing table when it detects anEmscripten-style
__indirect_function_tableimport or export. Thefuzzer would sometimes generate such a module, run
wasm-spliton it,and crash due to table corruption.
Fix (Path A): Modify
Split.can_run_on_wasminfuzz_opt.pytodetect the presence of
__indirect_function_tableand skip the testfor such modules.
Verification:
__indirect_function_tableis correctly skipped.Follow-up: A separate PR will address the root cause in
src/ir/module-splitting.cppby no longer reusing Emscripten tables (Path B).Fixes #8106.